/**
 */
package psm.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

import psm.AbstractWidget;
import psm.PanelGroup;
import psm.PsmPackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Panel Group</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link psm.impl.PanelGroupImpl#getAbstractWidget <em>Abstract Widget</em>}</li>
 *   <li>{@link psm.impl.PanelGroupImpl#getRepetitions <em>Repetitions</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class PanelGroupImpl extends AbstractWidgetImpl implements PanelGroup {
	/**
	 * The cached value of the '{@link #getAbstractWidget() <em>Abstract Widget</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getAbstractWidget()
	 * @generated
	 * @ordered
	 */
	protected EList<AbstractWidget> abstractWidget;

	/**
	 * The default value of the '{@link #getRepetitions() <em>Repetitions</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getRepetitions()
	 * @generated
	 * @ordered
	 */
	protected static final int REPETITIONS_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getRepetitions() <em>Repetitions</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getRepetitions()
	 * @generated
	 * @ordered
	 */
	protected int repetitions = REPETITIONS_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected PanelGroupImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return PsmPackage.Literals.PANEL_GROUP;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<AbstractWidget> getAbstractWidget() {
		if (abstractWidget == null) {
			abstractWidget = new EObjectContainmentEList<AbstractWidget>(AbstractWidget.class, this, PsmPackage.PANEL_GROUP__ABSTRACT_WIDGET);
		}
		return abstractWidget;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getRepetitions() {
		return repetitions;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setRepetitions(int newRepetitions) {
		int oldRepetitions = repetitions;
		repetitions = newRepetitions;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, PsmPackage.PANEL_GROUP__REPETITIONS, oldRepetitions, repetitions));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case PsmPackage.PANEL_GROUP__ABSTRACT_WIDGET:
				return ((InternalEList<?>)getAbstractWidget()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case PsmPackage.PANEL_GROUP__ABSTRACT_WIDGET:
				return getAbstractWidget();
			case PsmPackage.PANEL_GROUP__REPETITIONS:
				return getRepetitions();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case PsmPackage.PANEL_GROUP__ABSTRACT_WIDGET:
				getAbstractWidget().clear();
				getAbstractWidget().addAll((Collection<? extends AbstractWidget>)newValue);
				return;
			case PsmPackage.PANEL_GROUP__REPETITIONS:
				setRepetitions((Integer)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case PsmPackage.PANEL_GROUP__ABSTRACT_WIDGET:
				getAbstractWidget().clear();
				return;
			case PsmPackage.PANEL_GROUP__REPETITIONS:
				setRepetitions(REPETITIONS_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case PsmPackage.PANEL_GROUP__ABSTRACT_WIDGET:
				return abstractWidget != null && !abstractWidget.isEmpty();
			case PsmPackage.PANEL_GROUP__REPETITIONS:
				return repetitions != REPETITIONS_EDEFAULT;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (repetitions: ");
		result.append(repetitions);
		result.append(')');
		return result.toString();
	}

} //PanelGroupImpl
